import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPool {

    public static class ThreadPoolFixed {
        public static void main(String[] args) {
            //设置线程池大小为3
            ExecutorService fixedThreadPool = Executors.newFixedThreadPool(3);
            for (int i = 0; i < 10; i++) {
                final int index = i;
                fixedThreadPool.execute(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            System.out.println(index+"当前线程"+Thread.currentThread().getName());
                            Thread.sleep(2000);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                });
            }
//            fixedThreadPool.shutdown();
        }
    }
}
